package com.szyjjk.service;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.szyjjk.entity.RunModelInfo;
import com.szyjjk.entity.RunModelInfoExample;
import com.szyjjk.mapper.RunModelInfoMapper;

@Service
@Transactional(readOnly = true)
public class RunModelInfoService {

    @Autowired
    private RunModelInfoMapper runModelInfoMapper;

    /**
     * 查看所有
     * @return
     */
    public  List<RunModelInfo> findList(){
    	
    	try {
			return runModelInfoMapper.selectByExample(new RunModelInfoExample());
		} catch (Exception e) {
			e.printStackTrace();
		}
    	return new ArrayList<RunModelInfo>();
    }
    public  List<RunModelInfo> findListbystate(int state){

    	try {
			RunModelInfoExample example = new RunModelInfoExample();
			example.createCriteria().andStateEqualTo(state);
			return runModelInfoMapper.selectByExample(example);
		} catch (Exception e) {
			e.printStackTrace();
		}
    	return new ArrayList<RunModelInfo>();
    }
    /**
     * 根据类型更新
     */
    @Transactional(readOnly = false, propagation = Propagation.REQUIRED)
    public void updateById(RunModelInfo run){
    	
    	try {
    		runModelInfoMapper.updateByType(run);
		} catch (Exception e) {
			e.printStackTrace();
		}
    }
}
